import subprocess

def check_mysql_status():
    try:
        # 使用 sc 命令检查 MySQL 服务状态
        result = subprocess.run(['sc', 'query', 'MySQL'],
                                stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
        if "RUNNING" in result.stdout:
            status = "running"
        else:
            status = "not running"
    except FileNotFoundError:
        # 如果 sc 命令不可用，则打印错误消息
        print("Error: sc command not found.")
        status = "unknown"
    except Exception as e:
        # 处理其他可能的异常
        print(f"An error occurred: {e}")
        status = "unknown"

    return status

if __name__ == "__main__":
    status = check_mysql_status()
    print(f"MySQL service status: {status}")